.slider {
  max-width: 300px;
  height: 200px;
  margin: 20px auto;
  position: relative;
}
.slide1,.slide2 {
  position: absolute;
  width: 100%;
  height: 100%;
}
.slide1 {
  background: url("image1.jpg")no-repeat center;
      background-size: cover;
    animation:fade 8s infinite;
-webkit-animation:fade 8s infinite;

} 
.slide2 {
  background: url("image2.jpg")no-repeat center;
      background-size: cover;
    animation:fade2 8s infinite;
-webkit-animation:fade2 8s infinite;
}
@keyframes fade
{
  0%   {opacity:1}
  50% { opacity: 0}
  100% { opacity: 1}
}
@keyframes fade2
{
  0%   {opacity:0}
  50% {opacity: 1;}
  100% { opacity: 0}
}
